--This is called once when the game initially starts up
function love.load()
  --Load all of the external files needed by the game. It adds a little bit of load time, 
  --but keeps everything really tidy to self-contain everything in its own file.
  Gamestate = require('gamestate')
  Camera = require('camera')
  require('mainMenu')
  require('helpMenu')
  require('game')
  require('mapGen')
  
  love.graphics.setBackgroundColor(0,0,0,255)
  
  --This section gets the player's screen resolution and then sets the window size to 80% of that.
  --This is also useful since LOVE can automatically scale graphics to fit different sizes.
  --Screen scaling is applied at the beginning of love.draw() inside each state
  screen = {}
  isFullscreen = false
  love.graphics.setMode(0,0, false, true, 0)
  screen.w = love.graphics.getWidth()
  screen.h = love.graphics.getHeight()
  screen.scale = (0.8)*(screen.w/1920)
  
  love.graphics.setMode(1920*screen.scale,1080*screen.scale,false,true,0)
  love.mouse.setVisible(true)

  --Initialize and start the state machine
  Gamestate.registerEvents()
  Gamestate.switch(mainMenu)
end

--For testing and debugging purposes
function love.draw()
  if debug then
  love.graphics.print("FPS: "..tostring(love.timer.getFPS( )), 0, 0)
  end
end


function toggleFullscreen()
  if isFullscreen then
    screen.scale = screen.w/1920
    love.graphics.setMode(screen.w,screen.h,true,true,0)
  else
    screen.scale = (0.8)*screen.w/1920
    love.graphics.setMode(1920*screen.scale,1080*screen.scale,false,true,0)
  end
end